package demo2;

class Student{
    String name  ;
    int score ;

    public Student(String name, int score) {
        this.name = name;
        this.score = score;
    }

}
public class Test3  {

    public static void main(String[] args) {
        try{
            func();
        }catch (NameException e){
            e.printStackTrace();
            System.out.println("处理名字错误异常");
        }catch(AgeException e){
            e.printStackTrace();
            System.out.println("处理年龄错误异常");
        }finally {
            System.out.println("处理完成,正确");
        }
    }
    static void func() throws NameException,AgeException{
        Student student = new Student("张三",1) ;
        if(!student.name.equals("张三")){
            throw new NameException("名字错误") ;
        }else if( student.score != 10){
            throw new AgeException("年龄错误") ;
        }else {
            System.out.println("正确");
        }
    }



}
